<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <style>
      body {
        height: 2000px;
        background-color: aqua;
      }
    </style>
  </head>
  <body>
    <script>
      function throttle(fn, wait) {
        let lastTime = 0;
        return function (...args) {
          const now = Date.now();
          if (now - lastTime >= wait) {
            lastTime = now;
            fn();
          }
        };
      }

      function handleScroll() {
        console.log("滚动事件处理函数");
      }

      // 使用节流函数
      const throttledScroll = throttle(handleScroll, 200); // 每 200 毫秒处理一次滚动事件

      // 绑定滚动事件
      window.addEventListener("scroll", throttledScroll);
    </script>
  </body>
</html>
